package model;

import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.persistence.Version;

@Entity
@Table(name = "t_user")
public class User implements java.io.Serializable {
	private static final long serialVersionUID = -2114192102985611514L;

	// Fields
	private Long id;
	private String accounts;
	private String nickName;
	private String realName;
	private Integer sex;
	private Date birthday;
	private String idCard;
	private String password;
	private String mobile;
	private Integer avatar;
	private String phone;
	private String email;
	private Integer isMarried;
	private String industry;
	private String job;
	private Integer salary;
	private String homeAddress;
	private String workAddress;
	private String interest;
	private Integer isEnable;
	private Integer version;
	private Date createDt;
	
	private Set<SysRole> roles;

	// Constructors

	/** default constructor */
	public User() {
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "id", nullable = false)
	public Long getId() {
		return this.id;
	}

	@Column(name = "accounts", nullable = false, length = 16)
	public String getAccounts() {
		return this.accounts;
	}

	@Column(name = "nick_name", length = 50)
	public String getNickName() {
		return this.nickName;
	}

	@Column(name = "real_name", length = 50)
	public String getRealName() {
		return this.realName;
	}

	@Column(name = "email", length = 50)
	public String getEmail() {
		return this.email;
	}

	@Column(name = "home_address", length = 250)
	public String getHomeAddress() {
		return this.homeAddress;
	}
	
	@Version
	public Integer getVersion() {
		return version;
	}

	@Column(name = "id_card", length = 30)
	public String getIdCard() {
		return this.idCard;
	}

	@Column(name = "industry", length = 200)
	public String getIndustry() {
		return this.industry;
	}

	@Column(name = "sex")
	public Integer getSex() {
		return this.sex;
	}

	@Column(name = "interest", length = 500)
	public String getInterest() {
		return this.interest;
	}

	@Column(name = "is_married")
	public Integer getIsMarried() {
		return this.isMarried;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "birthday", length = 10)
	public Date getBirthday() {
		return this.birthday;
	}

	@Column(name = "avatar")
	public Integer getAvatar() {
		return this.avatar;
	}

	@Column(name = "job", length = 100)
	public String getJob() {
		return this.job;
	}

	@Column(name = "mobile", length = 20)
	public String getMobile() {
		return this.mobile;
	}

	@Column(name = "work_address", length = 250)
	public String getWorkAddress() {
		return this.workAddress;
	}

	@Column(name = "password", length = 50)
	@Transient
	public String getPassword() {
		return this.password;
	}

	@Column(name = "phone", length = 20)
	public String getPhone() {
		return this.phone;
	}

	@ManyToMany
	@JoinTable(
		name = "t_user_role",
		joinColumns = @JoinColumn(name = "user_id"),
		inverseJoinColumns = @JoinColumn(name = "role_id")
	)
	public Set<SysRole> getRoles() {
		return roles;
	}

	@Column(name = "salary")
	public Integer getSalary() {
		return this.salary;
	}

	@Column(name = "is_enable")
	public Integer getIsEnable() {
		return this.isEnable;
	}

	@Column(name = "create_dt", length = 19)
	public Date getCreateDt() {
		return this.createDt;
	}

	public void setAccounts(String accounts) {
		this.accounts = accounts;
	}

	public void setAvatar(Integer avatar) {
		this.avatar = avatar;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public void setCreateDt(Date createDt) {
		this.createDt = createDt;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setHomeAddress(String homeAddress) {
		this.homeAddress = homeAddress;
	}

	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}

	public void setIndustry(String industry) {
		this.industry = industry;
	}

	public void setInterest(String interest) {
		this.interest = interest;
	}

	public void setIsEnable(Integer isEnable) {
		this.isEnable = isEnable;
	}

	public void setIsMarried(Integer isMarried) {
		this.isMarried = isMarried;
	}

	public void setJob(String job) {
		this.job = job;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public void setRoles(Set<SysRole> roles) {
		this.roles = roles;
	}

	public void setSalary(Integer salary) {
		this.salary = salary;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

	public void setId(Long userId) {
		this.id = userId;
	}

	public void setWorkAddress(String workAddress) {
		this.workAddress = workAddress;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

}